package com.al.service;

import java.sql.SQLException;
import java.util.List;

import com.al.dao.StudentDao;
import com.al.entity.Student;

public class StudentService {
	StudentDao studentDao = new StudentDao();

	public List<Student> findAll() {
		
		try {
			return studentDao.findAll();
		} catch (ClassNotFoundException | SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void deleteById(String id) {
		try {
			studentDao.deleteById(id);
		} catch (ClassNotFoundException | SQLException e) {
			e.printStackTrace();
		}
		
	}

	public Student findById(String id) {
		try {
			return studentDao.findById(id);
		} catch (ClassNotFoundException | SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void upeate(String id, String name, Integer age, String gender, String major, Long phone) {
		try {
			int i = studentDao.update(id,name,age,gender,major,phone);
		} catch (ClassNotFoundException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void save(String id, String name, Integer age, String gender, String major, Long phone) {
		try {
			int i = studentDao.save(id,name,age,gender,major,phone);
		} catch (ClassNotFoundException | SQLException e) {
			e.printStackTrace();
		}
	}

}
